import { __private, _decorator, Node, AssetManager } from "cc";
import { Constructor, PoolHandlerComponent } from "../pool/NodeGroup";
import FragmentManager, { AddListener, Layer, RemoveListener } from "../FragmentManager";

export default abstract class View implements AddListener, RemoveListener {

    readonly isAddBefore: boolean = this.onAddBefore !== View.prototype.onAddBefore;

    readonly isAdd: boolean = this.onAdd !== View.prototype.onAdd;

    readonly isRemoveBefore: boolean = this.onRemoveBefore !== View.prototype.onRemoveBefore;

    readonly isRemove: boolean = this.onRemove !== View.prototype.onRemove;

    poolComponent: Constructor<PoolHandlerComponent> | string | undefined;

    single: boolean = true;

    safeArea: boolean = false;

    abstract layer(): Layer;

    abstract create(root: Node): { prefab: string, bundle?: string | AssetManager.Bundle } | Node;

    async onAddBefore(manager: FragmentManager, view: View, node: Node, root: Node, params: {}) {
        return Promise.resolve()
    };

    onAdd(manager: FragmentManager, view: View, node: Node) {

    }

    async onRemoveBefore(manager: FragmentManager, view: View, node: Node, root: Node, params: {}) {
        return Promise.resolve()
    };

    onRemove(manager: FragmentManager, view: View, node: Node, destroy: boolean) {

    }
}